package com.wss.day06.string;

/**
 * @author wangshaoshuai
 * @desc TODO
 * @date 2025/4/26
 */
public class Test {
    public static void main(String[] args) {
        final int COUNT = 100000;


        long startTime1 = System.currentTimeMillis();
        String str1 = "";
        for (int i = 0; i < COUNT; i++) {
            str1 += "a";
        }
        long endTime1 = System.currentTimeMillis();
        System.out.println("String + 拼接耗时: " + (endTime1 - startTime1) + "ms");


        long startTime2 = System.currentTimeMillis();
        StringBuilder str2 = new StringBuilder();
        for (int i = 0; i < COUNT; i++) {
            str2.append("a");
        }
        long endTime2 = System.currentTimeMillis();
        System.out.println("StringBuilder拼接耗时: " + (endTime2 - startTime2) + "ms");
    }
}
